| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkMemory::LinearPager< T, U > Class Template Referencefinal

A pager using a linear allocation algorithm. More...

## Public Member Functions
| LinearPager (unsigned long long pageSize, UniquePtr< MemorySpaceAllocator< U >> allocator=makeUnique< DefaultMemorySpaceAllocator< U >>()) noexcept
| LinearPager (const LinearPager &) noexcept=delete
| LinearPager (LinearPager &&) noexcept=default
unsigned long long | getPageSize () const
unsigned long long | getCurrentOffset () const
unsigned long long | getAllocatedPageCount () const
unsigned long long | getAvailablePageCount () const
T | allocate (unsigned long long size, unsigned long long alignment=1)
void | reset ()
unsigned long long | getCurrentPageFreeMemory () const
LinearPager & | operator= (const LinearPager &) noexcept=delete
LinearPager & | operator= (LinearPager &&) noexcept=default

## Detailed Description

### template<typename T = char*, typename U = DefaultMemorySpace>
class nkMemory::LinearPager< T, U >

A pager using a linear allocation algorithm.

A linear pager will allocate sequentially in the active page. When the page is full, a new page is allocated. Resetting the pager resets all allocations. This kind of pager can be useful in scenarios where allocations are used for a purpose and can be fred right after.
For instance, in a 3d renderer, it can be used to page resources used on a per frame basis (allocate for the frame, reset, reuse allocations for next frame).

- T represents the return type from allocations.
- U is the kind of memory space to use.

## Constructor & Destructor Documentation

## ◆ LinearPager() [1/3]

template<typename T = char*, typename U = DefaultMemorySpace>

nkMemory::LinearPager< T, U >::LinearPager | ( | unsigned long long | pageSize,
|  | UniquePtr< MemorySpaceAllocator< U >> | allocator = `makeUnique< DefaultMemorySpaceAllocator< U >>()`
| ) |  |
| noexcept

Constructor.

Parameters

  pageSize | The size wanted for pages within the pager, in number of elements.
  allocator | The memory space allocator, allowing to customize how the pages are allocated.

## ◆ LinearPager() [2/3]

template<typename T = char*, typename U = DefaultMemorySpace>

nkMemory::LinearPager< T, U >::LinearPager | ( | const LinearPager< T, U > & |  | ) |
| delete noexcept

Copy constructor.

## ◆ LinearPager() [3/3]

template<typename T = char*, typename U = DefaultMemorySpace>

nkMemory::LinearPager< T, U >::LinearPager | ( | LinearPager< T, U > && |  | ) |
| default noexcept

Move constructor.

## Member Function Documentation

## ◆ getPageSize()

template<typename T = char*, typename U = DefaultMemorySpace>

unsigned long long nkMemory::LinearPager< T, U >::getPageSize | ( |  | ) | const

Returns
  The page size used in the pager.

## ◆ getCurrentOffset()

template<typename T = char*, typename U = DefaultMemorySpace>

unsigned long long nkMemory::LinearPager< T, U >::getCurrentOffset | ( |  | ) | const

Returns
  The current offset within the active page.

## ◆ getAllocatedPageCount()

template<typename T = char*, typename U = DefaultMemorySpace>

unsigned long long nkMemory::LinearPager< T, U >::getAllocatedPageCount | ( |  | ) | const

Returns
  The number of pages currently allocated.

## ◆ getAvailablePageCount()

template<typename T = char*, typename U = DefaultMemorySpace>

unsigned long long nkMemory::LinearPager< T, U >::getAvailablePageCount | ( |  | ) | const

Returns
  The number of pages still available.

## ◆ allocate()

template<typename T = char*, typename U = DefaultMemorySpace>

T nkMemory::LinearPager< T, U >::allocate | ( | unsigned long long | size,
|  | unsigned long long | alignment = `1`
| ) |  |

Requests an allocation.

Parameters

  size | The size needed for the allocation, in number of elements.
  alignment | The alignment needed for the allocation.

Returns
  An allocation fitting the conditions given, if possible. If not, it will return a default constructed object.

Remarks
  Typically, a failure in allocating an object is due to the page size being too small.

## ◆ reset()

template<typename T = char*, typename U = DefaultMemorySpace>

void nkMemory::LinearPager< T, U >::reset | ( |  | ) |

Resets the status of the pager. This will make the pager reset its current tracking within the pages. Note that no memory will be freed. The point is to make already allocated memory usable again.

## ◆ getCurrentPageFreeMemory()

template<typename T = char*, typename U = DefaultMemorySpace>

unsigned long long nkMemory::LinearPager< T, U >::getCurrentPageFreeMemory | ( |  | ) | const

Returns
  The remaining available size within active page.

## ◆ operator=() [1/2]

template<typename T = char*, typename U = DefaultMemorySpace>

LinearPager& nkMemory::LinearPager< T, U >::operator= | ( | const LinearPager< T, U > & |  | ) |
| delete noexcept

Copy assignment.

## ◆ operator=() [2/2]

template<typename T = char*, typename U = DefaultMemorySpace>

LinearPager& nkMemory::LinearPager< T, U >::operator= | ( | LinearPager< T, U > && |  | ) |
| default noexcept

Move assignment.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsMemory/Pagers/Linear/LinearPager.h